﻿using System;
using System.Collections.Generic;
using System.Linq;
using SdmxMl.Manager;

namespace Ch.Admin.Bfs.Sms.Sdmx.Extension.CodeBook.Meta
{
    // Summary:
    //     Provides data for a cancelable event.
    public class ModuleBookEventArgs : EventArgs
    {
        // Summary:
        //     Initializes a new instance of the System.ComponentModel.CancelEventArgs class
        //     with empty FullId.
        public ModuleBookEventArgs()
        {
            FullId = string.Empty;
            ContentModuleType = TableOfContents.Overview;
        }
       
        //
        // Summary:
        //     Initializes a new instance of the System.ComponentModel.CancelEventArgs class
        //     with maintenable artefact specified with full ID and book usage module
        //
        public ModuleBookEventArgs(string maintenableFullId, TableOfContents tocModule)
        {
            FullId = maintenableFullId;
            ContentModuleType = tocModule;
        }

        // Summary:
        //     Gets or sets a value indicating the maintenable artefact fullId.
        //
        // Returns:
        //     the full Id.
        public string FullId { get; set; }
        public TableOfContents ContentModuleType { get; set; }
    }

    /// <summary>
    /// Enumerates types of modules available for Codebook generation
    /// </summary>
    public enum TableOfContents
    {
        Book,
        Overview,
        Catalog,
        DataTables,
        Questionnaires,
        Hierarchies,
        Correspondences,
        Codelists
    }

    public static class MyExtensions
    {
        public static SdmxMl.Manager.SdmxArtefactType SdmxType(this TableOfContents toc)
        {
            SdmxArtefactType ArType = SdmxMl.Manager.SdmxArtefactType.None;
            switch (toc)
            {
                case TableOfContents.Overview:
                case TableOfContents.Book:
                case TableOfContents.Questionnaires:
                    ArType = SdmxArtefactType.MetadataSet;
                    break;
                case TableOfContents.Catalog:
                    ArType = SdmxArtefactType.Concepts;
                    break;
                case TableOfContents.DataTables:
                    ArType = SdmxArtefactType.KeyFamilies;
                    break;
                case TableOfContents.Codelists:
                    ArType = SdmxArtefactType.CodeLists;
                    break;
                case TableOfContents.Correspondences:
                    ArType = SdmxArtefactType.StructureSets;
                    break;
                case TableOfContents.Hierarchies:
                    ArType = SdmxArtefactType.HierarchicalCodelists;
                    break;
                default:
                    ArType = SdmxArtefactType.None;
                    break;
            }

            return ArType;

        }
    } 

}
